package org.corey.wyp.command
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import mx.controls.Alert;
	import mx.rpc.IResponder;
	
	import org.corey.wyp.business.PropertyManagerDelegate;
	import org.corey.wyp.event.EditSpecialCalendarEvent;
	import org.corey.wyp.model.ProperityModelLocator;
	import org.corey.wyp.vo.Calendar;
	
	public class EditSpecialCalendarCommand implements ICommand,IResponder
	{
		public var e:EditSpecialCalendarEvent;
		
		public function EditSpecialCalendarCommand()
		{
			
		}
		public function execute(event:CairngormEvent):void{
			var pm:PropertyManagerDelegate=new PropertyManagerDelegate(this);
			var editCalendarEvent:EditSpecialCalendarEvent=EditSpecialCalendarEvent(event);
			e=editCalendarEvent;
			pm.getCalendarAccount(editCalendarEvent.year,editCalendarEvent.month,editCalendarEvent.date);
		}
		
		public function result(event:Object):void{
			if(event.result!=null){
				var ca:Calendar=Calendar(event.result);
				Alert.show(ca.id+":id");
				ProperityModelLocator.getInstance().application.today=Calendar(event.result);
			}else{
				var c:Calendar=new Calendar();
				c.year=e.year;
				c.month=e.month;
				c.date=e.date;
				ProperityModelLocator.getInstance().application.today=c;
			}
		}
		
		public function fault(info:Object):void{
			Alert.show("fault:"+info.toString());
		}
	}
}